/**
 * Created by liuchuanyang on 2017/8/4.
 */

import _ from 'lodash';

// 1- 大屏设计
// 2- h5设计
// 3- pc定制 - web
// 4- 外链
// 5- pc设计 - web
// 6- h5定制
// 7- 大屏定制
const TYPE_H5 = [ 2, 6, '2', '6' ];
const TYPES_WEB = [ 1, 3, 5, 7, '1', '3', '5', '7' ];
const TYPES_PC = [ 3, 5, '3', '5' ];
const TYPES_BS = [ 1, 7, '1', '7' ];
const TYPES_CUSTOM = [ 3, 6, 7, '3', '6', '7' ];
const TYPES_DESIGN = [ 1, 2, 5, '1', '2', '5' ];
const TYPES_LINK = [ 4, '4' ];

const isPageTypeH5 = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPE_H5, pageType) >= 0;
}

const isPageTypeWeb = (page) => {
    return isPageTypePc(page) || isPageTypeBs(page);
}

const isPageTypePc = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPES_PC, pageType) >= 0;
}

const isPageTypeBs = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPES_BS, pageType) >= 0;
}

const isPageTypeCustom = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPES_CUSTOM, pageType) >= 0;
}

const isPageTypeDesign = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPES_DESIGN, pageType) >= 0;
}

const isPageTypeLink = (page) => {
    let pageType = _.get(page, "type") || page;

    return _.indexOf(TYPES_LINK, pageType) >= 0;
}

export default {
    isPageTypeH5,
    isPageTypeWeb,
    isPageTypePc,
    isPageTypeBs,
    isPageTypeCustom,
    isPageTypeDesign,
    isPageTypeLink
}
